export class Events {
    constructor() {
        this.events_ = {};
    }
    
    add(type, callback) {
        if (typeof type === "string" &&
            typeof callback === "function") {
            
            let eventList = this.events_[type];            
            if (typeof eventList === "undefined") {
                eventList = [callback];
            } else {
                eventList.push(callback);
            }
        }
        
        return this;
    }
    
    fire(type) {
        if (type) {
            let eventList = this.events_[type];
            
            if (eventList) {
                for (let i = 0, len = eventList.length;
                    i < len; i++) {
                
                    
                }
            }
            
        }
    }
    
    remove(type, es) {
        let eventList = this.events_[type];
        
        if (eventList instanceof Array) {
            if (typeof es === "function") {
                for (let i = 0, len = eventList.length;
                    i < len; i++){
                    
                    if (eventList[i] === es){
                        eventList.splice(i, 1);
                        break;
                    }
                }
            } else if (es instanceof Array) {
                for (var i = 0, len = es.length;
                    i < len; i++) {
                    
                    this.remove(type, es[i]);
                }
            } else {
                delete eventList;
            }            
        }
        return this;
    }
}